import express from "express";
import logger from './utils/logger'
import router from './router'
import session from 'express-session'
import cors from 'cors'
import http from 'http'
import socketSever from './utils/socketIo'
const app = express();
// Session 配置
app.use(session({
  secret: 'zxz', // 更换为你的密钥
  resave: false,
  saveUninitialized: false,
  cookie: { 
    maxAge: 15 * 60 * 1000 // 15分钟
  }
}))
const port = process.env.PORT || 3000;
app.use(express.json())
app.use(cors())
const sereve = http.createServer(app)
const io = new socketSever(sereve)

sereve.listen(port, () => {
  logger.info(`服务已启动： http://localhost:${port}`);
  router(app, io)
});